package com.commute.planner;

public class DistanceCalculator {

	DistanceCalculator(){
		
	}
	
public double calcDistance(double latA, double lonA, double latB, double lonB ){
		
		double a = Math.PI /180;
		
		double lon1 = lonA*a;
		double lat1 = latA*a;
		
		double lon2 = lonB*a;
		double lat2 = latB*a;
		double t1 = Math.sin(lat1) * Math.sin(lat2);
		double t2 = Math.cos(lat1) * Math.cos(lat2);
	    double t3 = Math.cos(lon1 - lon2);
	    double t4 = t2 * t3;
	    double t5 = t1 + t4;
	    double rad_dist = Math.atan(-t5/Math.sqrt(-t5 * t5 +1)) + 2 * Math.atan(1);
	    //changing into meters
	    double meter_distance = rad_dist*1.6093470878864446*3437.74677*1.1508*1000;
	    
	    return meter_distance;  
		
	}
	
	
}
